<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            margin: 0 auto;
            width: 500px;
        }
        #jumpTo{
            color: red;
            font-size: 30px;
        }
    </style>
</head>
<body>
    <div>
        <h2>恭喜您，支付成功</h2>
        <span id="jumpTo">10</span>秒后自动跳转返回首页
        <p><button>立即返回</button></p>
    </div>
</body>
<script>
    // 十秒-- 就是设置定时器每次减去1 然后赋值给jumpTo

    window.onload = function(){
        let timer = 10;
        let timer1 = setInterval(() => {
            timer--;
            jumpTo.innerHTML = timer;
            if(timer == 0){
                // clearInterval(timer1);  //这个是错误的 如果我清除了定时器 那么我就重复10;每次减1 
                location.href = 'index.html'
            }
        }, 1000);
    }
    const btn =document.querySelector('button');
    btn.addEventListener('click',()=>{
        location.href ='index.html'
    })
</script>
</html>